package com.lolineet.publisher.conf;

import com.lolineet.publisher.properties.PublishProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.lolineet.publisher.service.Publisher;

/**
 * @Auther lolineet
 * @Email tj.zhanghongwei@163.com
 * @Date 2021/8/27 10:25
 * @Description lolineet publish config
 */
@Configuration
@EnableConfigurationProperties(PublishProperties.class)
@ConditionalOnProperty(
        prefix = "lolineet.socket",
        name = "enable",
        havingValue = "true"
)
public class PublishConfig {
    @Autowired
    private PublishProperties publishProperties;

    @Bean
    @ConditionalOnMissingBean
    public Publisher socketIoService(){
        return new Publisher(publishProperties);
    }
}
